package com.coco.controller;
import com.coco.service.PeopleService;
import com.coco.entity.People;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RestController
@RequestMapping("/people")
public class PeopleController{


      private PeopleService peopleService;


      @Autowired
      public PeopleController(PeopleService peopleService) {
              this.peopleService = peopleService;
      }


      @GetMapping("/queryPage")
      public List<People> queryPage(@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,@RequestParam(name="pageSize", defaultValue="50") Integer pageSize) {
             List<People> recodes = peopleService.queryPage(pageNo,pageSize);
             return recodes;
      }


      @PostMapping("/add")
      public void add(@RequestBody People people){
             peopleService.add(people);
      }


      @PutMapping("/edit")
      public void edit(@RequestBody People people){
             peopleService.edit(people);
      }


      @DeleteMapping("/delById")
      public void delById(@RequestParam(name="id") Integer id){
             peopleService.delById(id);
      }
}
